home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 653 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  989 b 

  1. Path: news.trs-p.co.jp.!sat!sat
  2. From: sat@trs-p.co.jp (Ogura Satoru)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Copy commands - copy Binary files.
  5. Date: Fri, 05 Jan 1996 19:20:58 +0900
  6. Organization: T.R.S. Planning Inc., Tokyo.
  7. Message-ID: <sat-0501961920580001@sat.trs-p.co.jp>
  8. References: <peterf.54.000F9B13@gears.efn.org>
  9. NNTP-Posting-Host: sat.trs-p.co.jp
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=iso-2022-jp
  12.  
  13. Hi,
  14.  
  15. I suppose the file this program created has extra 0xff at the end,
  16. because the function feof() returns TRUE after you have read the EOF.
  17.  
  18. >    while (!feof(in))
  19. >     { fputc(fgetc(in), out); }
  20.  
  21.    int c;
  22.     while ( ( c = fgetc( in ) ) != EOF ) {
  23.         fputc( c, out );
  24.     }
  25.  
  26. will work correctly.
  27.  
  28.  
  29. I suppose you wonder why feof() doesn't return TRUE when no data is
  30. available to read.
  31. If the FILE is assigned to TERMINAL or PIPE, no data isn't always EOF.
  32.  
  33.  
  34. -------------
  35. Thank you!
  36. Satoru Ogura. T.R.S.Planning Inc., Tokyo
  37. sat@trs-p.co.jp
  38. -------------
  39.